package wechat.handler.resources;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import wechat.handler.resources.app.AppID1;
import wechat.handler.resources.app.AppID2;

public class AppFilter {
	
	private static Logger log = LoggerFactory.getLogger(AppFilter.class);
	
	private static AppID1 appID1;
	private static AppID2 appID2;
	private static String appID1_APPID;
	private static String appID2_APPID;
	
	static{
		appID1 = new AppID1();
		appID2 = new AppID2();
		appID1_APPID = appID1.getAppid();
		appID2_APPID = appID2.getAppid();
	}
	
	public AppFilter(){
		
	}
	
	
	public static InstanceResource chooseApp(String appid){
		log.info("AppFilter --- chooseApp appid=" + appid);
		if (appID1_APPID.equals(appid)) {
			return appID1;
		}
		else if (appID2_APPID.equals(appid)) {
			return appID2;
		}
		
		return null;
	}
	
	public static String getAppId(String str){
		log.info("AppFilter --- getAppId appid=" + str);
		if (str.contains(appID1_APPID)) {
			return appID1_APPID;
		}
		else if (str.contains(appID2_APPID)) {
			return appID2_APPID;
		}
		return null;
	}
}
